//
//  ResgitViewController.m
//  Faner
//
//  Created by apple on 15/10/29.
//  Copyright © 2015年 lanou3g.com蓝鸥科技有限公司. All rights reserved.
//

#import "ResgitViewController.h"
#import "PKRequestManager.h"
@interface ResgitViewController ()<UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UITextField *nameTextF;
@property (strong, nonatomic) IBOutlet UITextField *emailTextF;
@property (strong, nonatomic) IBOutlet UITextField *passwordTextF;

@end

@implementation ResgitViewController
- (IBAction)returnToBefore:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)SiguUpPersonInfo:(id)sender {
    NSString *nameStr = self.nameTextF.text;
    NSString *passwordStr = self.passwordTextF.text;
    NSString *emailStr = self.emailTextF.text;
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    parDic[@"uname"] = nameStr;
    parDic[@"passwd"] = passwordStr;
    parDic[@"email"] = emailStr;
    [PKRequestManager PKRequestManagerrequsetWithType:POST URLString:@"http://api2.pianke.me/user/reg" ParDIc:parDic finish:^(NSData *data) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        if ([dic[@"result"] integerValue] == 0) {
            UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:dic[@"data"][@"msg"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alter show];
        }else{
            UIAlertView *newAlter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"注册成功" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [newAlter show];
        }
    } error:^(NSError *error) {
        
    }];

}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0.212 green:0.742 blue:1.000 alpha:1.000];
    
    self.nameTextF.delegate = self;
    self.passwordTextF.delegate = self;
    self.passwordTextF.secureTextEntry = YES;
    self.emailTextF.delegate = self;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.nameTextF resignFirstResponder];
    [self.passwordTextF resignFirstResponder];
    [self.emailTextF resignFirstResponder];
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
